var editor;
KindEditor.ready(function(K) {
	editor = K.create('textarea[name="content"]', {
		resizeType : 1,
		allowPreviewEmoticons : false,
		allowImageUpload : false,
		items : [
			'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', 'italic', 'underline',
			'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
			'insertunorderedlist', '|', 'emoticons', 'image', 'link']
	});
	});
	
	
function valiadValue(val){
		var title=$("#title").val();
		var sHTML = editor.html();
		var column=$("#column").val();
		if($.trim(column)==''||$.trim(column)=='null'){
			alert("请选择栏目！");
			return ;
		}
		if($.trim(title)==''||$.trim(title)=='null'){
			alert("标题不能为空！");
			return ;
		}
		if($.trim(sHTML)==''||$.trim(sHTML)=='null'){
			alert("正文不能为空！");
			return;
		}else if(sHTML.length>2000){
			alert("正文不能超过2000个字符！");
			return;
		}
		$("#content").val($.trim(sHTML));
		var table=$("#filetable").find("input[type=\"checkbox\"]");
		var fileId="";
		for(var i=0;i<table.length;i++){
			fileId+="_"+table[i].value;
		}
		$("#fileArray").val(fileId);
		var url="";
		if(val=='save'){
			url="saveInfoReport.action";
		}else if(val=='update'){
			url="informationUpdate.action";
		}
		$.post(url,$("form").serialize(),function(data){
					if(data=='success'){
						alert("保存成功！");
						window.close();
						if(val=='save'){
						window.location.href="InformationReport.action";
						}else{
						var currentPage=$("#currentPage").val();
							window.opener.page(currentPage);
						}
					}else{
						alert("保存失败！");
					}
				});	
	}
	
function infoSaveUpdate(val){
		var title=$("#title").val();
		var sHTML = editor.html();
		var column=$("#column").val();
		if($.trim(column)==''||$.trim(column)=='null'){
			alert("请选择栏目！");
			return ;
		}
		if($.trim(title)==''||$.trim(title)=='null'){
			alert("标题不能为空！");
			return ;
		}
		if($.trim(sHTML)==''||$.trim(sHTML)=='null'){
			alert("正文不能为空！");
			return;
		}
		$("#content").val($.trim(sHTML));
		var table=$("#filetable").find("input[type=\"checkbox\"]");
		var fileId="";
		for(var i=0;i<table.length;i++){
			fileId+="_"+table[i].value;
		}
		$("#fileArray").val(fileId);
		var url="";
		if(val=='save'){
			url="saveInfoUser.action";
		}else if(val=='update'){
			url="informationUpdate.action";
		}
		$.post(url,$("form").serialize(),function(data){
					if(data=='success'){
						alert("保存成功！");
						window.close();
						if(val=='save'){
						window.location.href="infoInit.action";
						}else{
						var currentPage=$("#currentPage").val();
							window.opener.page(currentPage);
						}
					}else{
						alert("保存失败！");
					}
				});	
	}	
	